<template>
    <a-modal :title="'批量导入修改'" :visible="true" width="400px" @ok="submit" @cancel="reset">
        <div style="display:flex;    justify-content: center;">
                <fileUpload style="display:flex;flex-wrap: wrap;width:100px;marfin-left:10px"
                :uploadParams="getUploadParams()" :isMultiple="true" :number="1" @fileChange1="fileChange1"
                v-model="list"></fileUpload>
        </div>
    </a-modal>
</template>
    
<script>
import fileUpload from './upload/uploadfile.vue'
import globalData from '@/assets/js/common'
import { postAction } from '@/api/manage'


export default {
    components: {
        fileUpload,
    },
    data() {
        return {
            urlKey: 'basemgt-material/',
            list: [],
        }
    },

    created() {

    },
    computed: {
        jobNumber() {
            return this.$store.getters.userInfo.workNo || ''
        }
    },
    methods: {
        getUploadParams() {
            return { ...globalData.uploadParams }
        },
        fileChange1(list) {
            this.list = list
            console.log(this.list);
        },
        reset() {
            this.list = []
            this.$emit('closeExport')
        },
        submit() {
            if (!this.list.length) {
                this.$message.error('请先选择文件！')
            } else {
                const params = {
                    category: 20,
                    type: 20,
                    filePath: this.list[0].url,
                    jobNumber: this.jobNumber
                }
                postAction(`${this.urlKey}excel/task/submit`, params).then(res => {
                    if (res.code == 200) {
                        this.$message.success('提交上传任务成功！')
                        this.reset()
                    }else{
                        this.$message.error('提交上传任务失败！')
                    }
                })
            }

        }
    }
}
</script>
<style scoped>
.info-action {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
}

.ml-20 {
    margin-left: 20px;
}

.dynamic-delete-button {
    cursor: pointer;
    position: absolute;
    right: -40px;
    top: -4px;
    font-size: 24px;
    color: #999;
    transition: all 0.3s;
}

.dynamic-delete-button:hover {
    color: #777;
}

.dynamic-delete-button[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
}
</style>